<%@ page import="com.actimind.actitime.reports.BillingSummaryReportForm,
                 com.actimind.actitime.reports.BillingSummaryReportFilter,
                 com.actimind.actitime.Keys"%>
<%@ page errorPage="/error.jsp" %>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page autoFlush="false"  %>
<%@ page buffer="400kb" %>
<at:CheckLoggedIn/>

<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Billing Summary Report</title>
    <link rel="stylesheet" href="../css/at.css" type="text/css">
    <script language="JavaScript" src="../js/at.js"></script>
    <script language="JavaScript" src="../js/calendar.js?r=1"></script>
<script language="Javascript">
    <!--
    function confirm_submit()
    {
        with (document.forms[0])
        {
            if ( getDateWithPrefix('from') > getDateWithPrefix('to') )
            {
                alert("Date range is invalid, date To < date From.");
                fromDay.focus();
                return false;
            }
        }

        return true;
    }
    //-->
</script>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" onLoad="document.forms[0].autocomplete='off';">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="reports"/>
    <jsp:param name="pageAction" value="billingsummary"/>
</jsp:include>

<at:form action="/reports/billingsummary" onsubmit="return confirm_submit()" >
<input type="hidden" name="pageAction"/>
<input type="hidden" name="submitted" value="1"/>
<bean:define id="form" name="BillingSummaryReportForm" type="com.actimind.actitime.reports.BillingSummaryReportForm" />

<table width="770" align="center" cellspacing="0" cellpadding="4" border="0">
    <tr>
        <td class="pagetitle" valign="top">Billing Summary Report</td>
    </tr>
    <tr><td><at:errors /></td></tr>
</table>

<table width="770" align="center" cellspacing="0" cellpadding="4" border="0">
    <tr>
        <td class="formblocktitle" nowrap="1" width="48">STEP 1.</td>
        <td class="formblocktitle" colspan="2">CHOOSE REPORT TYPE</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td colspan="2">
            <table cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td><html:radio property="type" value="<%=String.valueOf( BillingSummaryReportForm.TYPE_TIME_REPORTED )%>" /></td>
                    <td class="text">Time reported for a date range</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td class="smallcomment">Report will include number of hours spent on the tasks (including incomplete tasks) within specified date range.</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td colspan="2">
            <table cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td><html:radio property="type" value="<%=String.valueOf( BillingSummaryReportForm.TYPE_TIME_SPENT_ON_COMPLETED_TASKS )%>" /></td>
                    <td class="text">Time spent on tasks completed within a date range</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td class="smallcomment">Report will include overall number of hours (starting from task creation) spent on the tasks that were completed within the specified date range.</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%">STEP 2.</td>
        <td class="formblocktitle" colspan="2">SPECIFY DATE RANGE</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td colspan="2"><%@include file="date_utils.jsp"%></td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%">STEP 3.</td>
        <td class="formblocktitle" colspan="2">CHOOSE TASKS TO REPORT BY</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td class="text" colspan="2"><html:radio property="tasksOption" value="<%=String.valueOf( BillingSummaryReportFilter.TASKS_OPTION_BILLABLE )%>" />Billable tasks</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td class="text" colspan="2"><html:radio property="tasksOption" value="<%=String.valueOf( BillingSummaryReportFilter.TASKS_OPTION_NON_BILLABLE )%>" />Non-Billable tasks</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td class="text" colspan="2"><html:radio property="tasksOption" value="<%=String.valueOf( BillingSummaryReportFilter.TASKS_OPTION_ALL )%>" />Both Billable and Non-Billable tasks</td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%">STEP 4.</td>
        <td class="formblocktitle" nowrap="1" >CHOOSE CUSTOMERS TO SHOW</td>
        <td width="70%">
        <at:select property="customerId" childSelect="projectId" firstChildText="-- All projects --" firstChildValue="0" style="width: 190px" width="190" maxlength="31">
            <at:option value="">-- All customers --</at:option>
            <at:options collection="<%=Keys.CUSTOMERS_LIST_KEY%>" property="id" labelProperty="name"/>
        </at:select>
        </td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%">STEP 5.</td>
        <td class="formblocktitle" nowrap="1" >CHOOSE PROJECTS TO SHOW</td>
        <td>
        <at:select property="projectId" parentSelect="customerId" firstChildText="-- All projects --" firstChildValue="0" style="width: 190px" width="190" maxlength="31">
            <option value=""> </option>
            <option value=""> </option>
            <option value=""> </option>
            <option value=""> </option>
            <at:options collection="<%=Keys.PROJECTS_LIST_KEY%>" property="id" parentProperty="customerId" labelProperty="name"/>
        </at:select>
        </td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%">STEP 6.</td>
        <td class="formblocktitle" colspan="2">CHOOSE LEVEL OF DETAILS</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td class="text" colspan="2"><html:radio property="showTasks" value="true" />Show tasks</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td class="text" colspan="2"><html:radio property="showTasks" value="false" />Hide tasks</td>
    </tr>
    <tr>
        <td class="formblocktitle" nowrap="1" width="5%" bgcolor="#E5E5E5">STEP 7.</td>
        <td class="text" align="center" bgcolor="#E5E5E5" colspan="2">
            <table cellspacing="0" cellpadding="2" border="0" width="100%">
            <tr>
                <td width="40%" align="right"><input type="submit" onclick="this.form.pageAction.value='html'; return true;" value="Generate HTML Report"></td>
                <td class="text" align="center">-- OR --</td>
                <td width="50%" align="left"><input type="submit" onclick="this.form.action='<html:rewrite href='billingsummary.csv'/>'; this.form.pageAction.value='csv'; return true;" value="Generate CSV Report"></td>
            </tr>
            </table>
        </td>
    </tr>

</table>

</at:form>

</body>
</html>
